package com.guslegend.config;

import com.guslegend.interceptor.LoginInterceptor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

/**
 * @author: guslegend
 * @description: 登录拦截器
 * @create: 2025-05-28 19:27
 **/
@Slf4j
@Configuration
public class InterceptorConfig implements WebMvcConfigurer {
    public LoginInterceptor interceptor() {
        return new LoginInterceptor();
    }

    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        registry.addInterceptor(interceptor())
                //拦截的路径
                .addPathPatterns("/api/user/*/**", "/api/notify/*/**", "/api/address/*/**")
                //不拦截的路径
                .excludePathPatterns("/api/notify/*/get_change_pwd__code", "/api/notify/*/get_kaptcha",
                        "/api/notify/*/get_login_code", "/api/notify/*/get_register_code", "/api/user/*/login_by_code", "/api/user/*/login_by_password",
                        "/api/user/*/register", "/api/user/*/upload_headImg");
    }
}